package com.concurrency.controller;

import com.concurrency.example.cache.RedisClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RedisController {
    @Autowired
    RedisClient redisClient;

    @GetMapping("/setCache")
    public String setCache(@RequestParam("k") String k,
                           @RequestParam("v") String v) {
        redisClient.set(k, v);
        return "SUCCESS";
    }

    @GetMapping("/getCache")
    public String getCache(@RequestParam("k") String k) {
        return redisClient.get(k);
    }
}
